
#include "uart.h"
#include "same51n20a.h"

void uart_write_block(const uint8* bytes, uint16_t len) {
    if(len > 0) {
        for(uint16_t i = 0; i < len; i++) {
            SERCOM0_REGS->USART_INT.SERCOM_DATA = *bytes++;
		    while((SERCOM0_REGS->USART_INT.SERCOM_INTFLAG & SERCOM_USART_INT_INTFLAG_TXC_Msk) == 0);
        }
    } else {
        while(*bytes) {
            SERCOM0_REGS->USART_INT.SERCOM_DATA = *bytes++;
		    while((SERCOM0_REGS->USART_INT.SERCOM_INTFLAG & SERCOM_USART_INT_INTFLAG_TXC_Msk) == 0);
        }
    }
}

int uart_read_block(const uint8* bytes, uint16_t len) {
    (void) bytes; (void) len;
    return 0;
}

void uart_main_function(void) {
    
}

